package com.easylinkin.linkappapi.shigongyun.controller;

import com.easylinkin.linkappapi.machinery.dto.MachineryIotDeviceDto;
import com.easylinkin.linkappapi.machinery.vo.MachineryDeviceVo;
import com.easylinkin.linkappapi.shigongyun.service.MachineryMonitorBiService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import site.morn.rest.RestBuilders;
import site.morn.rest.RestMessage;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author zhengwen
 */
@Slf4j
@Api(value = "机械管理大屏", tags = {"机械管理大屏大屏接口"})
@RestController
@RequestMapping("/enterpriseEditionBi")
public class MachineryMonitorBiController {

    @Resource
    private MachineryMonitorBiService machineryMonitorBiService;


    /**
     * 根据条件获取机械设备信息
     *
     * @param machineryDeviceVo 机械设备条件vo
     * @return 机械设备信息
     */
    @PostMapping("/queryMachineryDevices")
    @ApiOperation("根据条件获取机械设备信息")
    public RestMessage queryMachineryDevices(@RequestBody MachineryDeviceVo machineryDeviceVo) {
        log.info("根据条件获取机械设备信息");
        List<MachineryIotDeviceDto> dtos = machineryMonitorBiService.queryMachineryDevices(machineryDeviceVo);
        return RestBuilders.successBuilder().data(dtos).build();
    }

    /**
     * 获取机械Iot设备类型告警数量统计
     *
     * @param machineryDeviceVo 机械设备条件vo
     * @return 机械Iot设备类型告警数量统计
     */
    @PostMapping("/countMachineryWarnGroupType")
    @ApiOperation("获取机械Iot设备类型告警数量统计")
    public RestMessage countMachineryWarnGroupType(@RequestBody MachineryDeviceVo machineryDeviceVo) {
        log.info("获取机械Iot设备类型告警数量统计");
        return machineryMonitorBiService.countMachineryWarnGroupType(machineryDeviceVo);
    }

    /**
     * 获取机械Iot设备告警数量统计时间分组
     *
     * @param machineryDeviceVo 机械设备条件vo
     * @return 机械Iot设备类型告警数量统计
     */
    @PostMapping("/countMachineryWarnByDay")
    @ApiOperation("获取机械Iot设备告警数量统计时间分组")
    public RestMessage countMachineryWarnByDay(@RequestBody MachineryDeviceVo machineryDeviceVo) {
        log.info("获取机械Iot设备告警数量统计时间分组");
        return machineryMonitorBiService.countMachineryWarnByDay(machineryDeviceVo);
    }

    /**
     * 获取机械Iot设备今日运行次数统计
     *
     * @param machineryDeviceVo 机械设备条件vo
     * @return 机械Iot设备今日运行次数统计
     */
    @PostMapping("/countMachineryOperationToday")
    @ApiOperation("获取机械Iot设备今日运行次数统计")
    public RestMessage countMachineryOperationToday(@RequestBody MachineryDeviceVo machineryDeviceVo) {
        log.info("获取机械Iot设备今日运行次数统计");
        return machineryMonitorBiService.countMachineryOperationToday(machineryDeviceVo);
    }

}
